<?php
ob_start();
require_once substr(dirname(__FILE__),0,-1).'sub/init.php';
if(!is_mobile())header("Location: ".Href('my_msg'));

$t=($t!='sx' && $t!='tz' && $t!='hi' && $t!='see' && $t!='tip_detail' && empty($submitok))?'sx':$t;

$currfields = 'grade,tipnum';
require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'cache/udata.php';
require_once ZEAI.'cache/config_vip.php';

if(@!in_array('chat',$navarr) && $t=='sx'){header("Location: ".HOST."/m/my_msg.php?t=tz");exit;}
if(@!in_array('hi',$navarr) && $t=='hi'){header("Location: ".HOST."/m/my_msg.php?t=tz");exit;}

$cook_grade   = $row['grade'];
$data_tipnum  = $row['tipnum'];
$chat_daylooknum  = json_decode($_VIP['chat_daylooknum']);
$chat_loveb       = json_decode($_VIP['chat_loveb']);
$chat_duifangfree = json_decode($_VIP['chat_duifangfree'],true);
$kf_tel=dataIO($_ZEAI['kf_tel'],'out');$kf_mob=dataIO($_ZEAI['kf_mob'],'out');
$kf_wxpic_url = UP.dataIO($_ZEAI['kf_wxpic'],'out');

function newdiandata() {
	global $db,$cook_uid,$data_tipnum;
	$num_sx = $db->COUNT(__TBL_MSG__,"new=1 AND ifdel=0 AND uid=".$cook_uid);
	$num_tz = $db->COUNT(__TBL_TIP__,"new=1 AND kind<>3 AND uid=".$cook_uid);
	$num_hi = $db->COUNT(__TBL_TIP__,"new=1 AND kind=3 AND uid=".$cook_uid);
	$num_see= $db->COUNT(__TBL_CLICKHISTORY__,"new=1 AND uid=".$cook_uid);
	$tipnum = intval($num_tz+$num_hi+$num_sx);
	if($tipnum>0 && $data_tipnum!=$tipnum){
		$db->query("UPDATE ".__TBL_USER__." SET tipnum=$tipnum WHERE id=".$cook_uid);
	}
	return array('num_tz'=>$num_tz,'num_sx'=>$num_sx,'num_see'=>$num_see,'num_hi'=>$num_hi,'tipnum'=>$tipnum);
}
if($submitok == 'ajax_sx_clearmsg'){
	if(!ifint($uid))exit(JSON_ERROR);
	$n_my = $db->COUNT(__TBL_MSG__,"ifdel=0 AND new=1 AND senduid=".$uid." AND uid=".$cook_uid);
	if($n_my>$data_tipnum){
		$endnum=0;
	}else{
		$endnum=$data_tipnum-$n_my;
	}
	if ($endnum != $data_tipnum)$db->query("UPDATE ".__TBL_USER__." SET tipnum=$endnum WHERE id=".$cook_uid);
	$SQL = " (uid=".$uid." AND senduid=".$cook_uid.") OR (senduid=".$uid." AND uid=".$cook_uid.") ";
	$db->query("UPDATE ".__TBL_MSG__." SET ifdel=".$cook_uid." WHERE ifdel=0 AND ".$SQL);
	//我发给对方，对方有没有删除
	$cont = $db->COUNT(__TBL_MSG__,"ifdel=".$uid." AND senduid=".$cook_uid." AND uid=".$uid);
	if ($cont > 0)$db->query("DELETE FROM ".__TBL_MSG__." WHERE ".$SQL);//对方已删除，清理
	$ret=array('flag'=>1)+newdiandata();
	json_exit($ret);
	
}elseif($submitok == 'ajax_tz_del'){
	if(!ifint($tid))exit(JSON_ERROR);
	$row = $db->ROW(__TBL_TIP__,"id","new=1 AND uid=".$cook_uid." AND id=".$tid);
	if ($row)$db->query("UPDATE ".__TBL_USER__." SET tipnum=tipnum-1 WHERE tipnum>=1 AND id=".$cook_uid);
	$db->query("DELETE FROM ".__TBL_TIP__." WHERE uid=".$cook_uid." AND id=".$tid);
	$ret=array('flag'=>1)+newdiandata();
	json_exit($ret);
	
}elseif($submitok == 'ajax_gift_div_msg'){
	if(!ifint($tid))exit(JSON_ERROR);
	$T = $db->ROW(__TBL_TIP__,"remark","id=".$tid);
	if ($T){$guid = $T[0];}else{exit(JSON_ERROR);}
    $rt=$db->query("SELECT a.senduid AS uid,a.new AS ifnew,b.title,b.picurl,b.price,c.nickname FROM ".__TBL_GIFT_USER__." a,".__TBL_GIFT__." b,".__TBL_USER__." c WHERE a.id=".$guid." AND a.uid=".$cook_uid." AND a.gid=b.id AND a.senduid=c.id LIMIT 1");
    if ($db->num_rows($rt)){
		$G = $db->fetch_array($rt,'name');
		$G['nickname'] = dataIO($G['nickname'],'out');
		$G['title']    = dataIO($G['title'],'out');
		$G['picurl']   = UP.$G['picurl'];
		if ($G['ifnew'] == 1){
			$db->query("UPDATE ".__TBL_TIP__." SET new=0 WHERE uid=".$cook_uid." AND kind=2 AND id=".$tid);
			$db->query("UPDATE ".__TBL_GIFT_USER__." SET new=0 WHERE uid=".$cook_uid." AND id=".$guid);
			$db->query("UPDATE ".__TBL_USER__." SET tipnum=tipnum-1 WHERE tipnum>=1 AND id=".$cook_uid);
		}
		$G = array('flag'=>'1') + $G;
		json_exit($G);
    }else{exit(JSON_ERROR);}
}elseif($submitok == 'ajax_msg_hi_div'){
	if(!ifint($tid))exit(JSON_ERROR);
	if(!in_array('hi',$navarr))json_exit(array('flag'=>0,'msg'=>'此功能已关闭'));
	$rt=$db->query("SELECT a.senduid,a.content,a.new,b.sex,b.nickname,b.photo_s,b.photo_f,b.photo_ifshow,b.flag FROM ".__TBL_TIP__." a,".__TBL_USER__." b WHERE a.kind=3 AND a.senduid=b.id AND a.uid=".$cook_uid." AND a.id=".$tid);
	if ($db->num_rows($rt)){
		$row = $db->fetch_array($rt,'num');
		$senduid = $row[0];
		$content = urlencode($row[1]);
		$new     = $row[2];
		$sex     = $row[3];
		$nickname= trimhtml(dataIO($row[4],'out'));
		$photo_s = $row[5];
		$photo_f = $row[6];
		$photo_ifshow = $row[6];
		$uflag = $row[6];
		if ($new == 1){
			$db->query("UPDATE ".__TBL_TIP__." SET new=0 WHERE uid=".$cook_uid." AND kind=3 AND id=".$tid);
			$db->query("UPDATE ".__TBL_USER__." SET tipnum=tipnum-1 WHERE tipnum>=1 AND id=".$cook_uid);
		}
		$photo_s=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');
		$ifhiher = ($db->COUNT(__TBL_TIP__,"senduid=".$cook_uid." AND uid=".$senduid." AND kind=3") > 0)?1:0;
		$ifchat = (in_array('chat',$navarr))?1:0;
		json_exit(array('flag'=>1,'tid'=>$tid,'uid'=>$senduid,'nickname'=>$nickname,'sex'=>$sex,'photo_s'=>$photo_s,'content'=>$content,'ifnew'=>$new,'ifhiher'=>$ifhiher,'ifchat'=>$ifchat));
	}
	exit(JSON_ERROR);
}
$newarr  = newdiandata();
$chatnum = $newarr['num_sx'];
$tznum   = $newarr['num_tz'];
$hinum   = $newarr['num_hi'];
$seenum  = $newarr['num_see'];
$chatnum_str = ($chatnum>0)?'<b id="num_sx"></b>':'';
$hinum_str   = ($hinum>0)?'<b id="num_hi"></b>':'';
$tznum_str   = ($tznum>0)?'<b id="num_tz"></b>':'';
$seenum_str  = ($seenum>0)?'<b id="num_see"></b>':'';
$nav='my_msg';
if($_ZEAI['m_mb']==2){require_once ZEAI.'m/my_msg2.php';exit;}?>
<!doctype html><html><head><meta charset="utf-8">
<title>消息通知-<?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<meta name="generator" content="Zeai.cn V8" />
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/my_msg.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/my_msg.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
body{background-color:#f8f8f8}
#backtop a{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.my_msg_top:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.box_hi dl dd{background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.6);}
.box_hi dl dd:before{border-right-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.6);}
.my_msg_nav a span.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.my_msg_top:before{background-image:url("<?php echo RES;?>m/img/my_bg.png");}
a.aQING{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
</style>
</head><body>
<?php
/*********消息正文*********/
if ($t == 'tip_detail'){
	if(!ifint($tid))zeaialert('{"title":"error_tid","btnt":"我知道了","url":"-1"}');
	$row = $db->ROW(__TBL_TIP__,"content,new,addtime,kind","uid=".$cook_uid." AND id=".$tid);
	if ($row){
		$content = dataIO($row[0],'out');
		$content = str_replace("aQING","zeaicolor",$content);
		$new     = $row[1];
		$addtime = YmdHis($row[2]);
		$kind    = $row[3];
		if ($new == 1){
			$db->query("UPDATE ".__TBL_TIP__." SET new=0 WHERE id=".$tid." AND uid=".$cook_uid);
			$db->query("UPDATE ".__TBL_USER__." SET tipnum=tipnum-1 WHERE tipnum>=1 AND id=".$cook_uid);
		}
		$kindT=($kind==1)?'系统消息':'红娘消息';
	}else{zeaialert('{"title":"消息不存在","btnt":"我知道了","url":"-1"}');}
	$mini_title=$kindT;
	require_once ZEAI.'m/top_mini.php';?>
	<style>
	body{background-color:#fff}
	.msg_detail{background-color:#fff;margin-top:5rem;padding:2rem 3rem 3rem 3rem;line-height:200%;font-size:1.6rem;text-align:left}
	.linebox{margin:2rem 0 0;z-index:0}</style>
    <div class="msg_detail">
		<div id="msgC"><?php echo $content;?></div>
        <div class="linebox"><div class="line "></div><div class="title BAI S14 C999"><?php echo $addtime; ?></div></div>
    </div>
	<script>
		function returnId(href,str){
			var hrefarr = href.split(str);
			var newhref=hrefarr[hrefarr.length-1];
			newhref=newhref.replace('/','');
			var id=newhref.replace('.html','');
			return id;
		}	
		//链接处理
		(function pcAreset(){//var mobAarr=['my_money','my_loveb','my_info'];
		zeai.listEach(zeai.tag(msgC,'a'),function(a){
			var href=a.href;
			//pc链接处理
			if (href.indexOf('/u/') !== -1){
				var uid=returnId(href,'/u/');
				a.onclick=function(){zeai.openurl(HOST+'/m/u'+zeai.ajxext+'uid='+uid);}
			}
			if (href.indexOf('/u.php?uid=') !== -1){
				var uid=returnId(href,'/u.php?uid=');
				a.onclick=function(){zeai.openurl(HOST+'/m/u'+zeai.ajxext+'uid='+uid);}
			}
			//
			if (href.indexOf('/video') !== -1){a.onclick=function(){zeai.openurl('<?php echo HOST;?>/?z=video');}}
			if (href.indexOf('/my_money') !== -1){a.onclick=function(){zeai.openurl(HOST+'/m/my_money'+zeai.extname);}}
			if (href.indexOf('/my_loveb') !== -1){a.onclick=function(){zeai.openurl(HOST+'/m/my_loveb'+zeai.extname);}}
			if (href.indexOf('/my_cert') !== -1){a.onclick=function(){zeai.openurl(HOST+'/m/my_cert'+zeai.extname);}}
			//if (href.indexOf('/my_tg') !== -1){a.onclick=function(){zeai.openurl('m/TG'+zeai.extname,'msg_detail','TG');}}
			if (href.indexOf('/my_info') !== -1){a.onclick=function(){zeai.openurl(HOST+'/m/my_info'+zeai.extname);}}
			if (href.indexOf('/my_photo') !== -1){a.onclick=function(){zeai.openurl(HOST+'/m/my_info'+zeai.extname);}}
			if (href.indexOf('/my.php') !== -1){a.onclick=function(){zeai.openurl('<?php echo HOST;?>/m/my'+zeai.extname);}}
			if (href.indexOf('/my_vip') !== -1){a.onclick=function(){zeai.openurl(HOST+'/m/my_vip'+zeai.extname);}}
			//约会
			if (href.indexOf('/dating_detail.php?fid=') !== -1){
				var fid=returnId(href,'/dating_detail.php?fid=');
				a.onclick=function(){zeai.openurl('<?php echo HOST;?>/m/dating.php?id='+fid);}
			}else if(href.indexOf('/dating/') !== -1){
				var fid=returnId(href,'/dating/');
				if(zeai.ifint(fid)){
					a.onclick=function(){zeai.openurl('<?php echo HOST;?>/m/dating.php?id='+fid);}
				}else{
					a.onclick=function(){zeai.openurl('<?php echo HOST;?>/m/dating.php');}
				}
			}
			//交友圈
			if(href.indexOf('/trend/') !== -1){
				var fid=returnId(href,'/trend/');
				if(zeai.ifint(fid)){
					a.onclick=function(){zeai.openurl('<?php echo HOST;?>/?z=trend&submitok=my');}
				}
			}
			//活动
			if (href.indexOf('/party_detail.php?fid=') !== -1){
				var fid=returnId(href,'/party_detail.php?fid=');
				a.onclick=function(){zeai.openurl(HOST+'/m/party_detail'+zeai.ajxext+'fid='+fid);}
			}else if(href.indexOf('/party/') !== -1){
				var fid=returnId(href,'/party/');
				if(zeai.ifint(fid)){
					a.onclick=function(){zeai.openurl(HOST+'/m/party_detail'+zeai.ajxext+'fid='+fid);}
				}else{
					a.onclick=function(){zeai.openurl('<?php echo mHref('party');?>');}
				}
			}
			//红包
			if (href.indexOf('/hongbao_detail.php?fid=') !== -1){
				var fid=returnId(href,'/hongbao_detail.php?fid=');
				a.onclick=function(){zeai.openurl('<?php echo HOST;?>/m/hongbao/detail'+zeai.ajxext+'fid='+fid);}
			}else if(href.indexOf('/hongbao/') !== -1){
				var fid=returnId(href,'/hongbao/');
				if(zeai.ifint(fid)){
					a.onclick=function(){zeai.openurl('<?php echo HOST;?>/m/hongbao/detail'+zeai.ajxext+'fid='+fid);}
				}else{
					a.onclick=function(){zeai.openurl('<?php echo HOST;?>/m/hongbao');}
				}
			}
			/*手机内部链接处理/http://www.yzlove.com/?z=dating&e=detail&a=23
			for(var m=0;m<mobAarr.length;m++){
				if (href.indexOf(mobAarr[m]) !== -1){
					a.onclick=function(){ZeaiM.page.load('m/'+pagestr+zeai.extname,'msg_detail',pagestr);}
				}
			}*/
			//a.removeAttribute("href");
		});
	})()
    </script>
    </body></html>
<?php exit;}
switch ($t) {
	case 'sx':$t_t  = '私信聊天';break;
	case 'tz':$t_t  = '系统通知';break;
	case 'hi':$t_t  = '收到招呼';break;
	case 'see':$t_t = '谁看过我';break;
}
$mini_class='top_mini4 zeaibg bgcolor';
$mini_L = '<em onClick="zeai.back()"><i class="ico" >&#xeaca;</i></em>';
$mini_title=$t_t;
require_once ZEAI.'m/top_mini.php';
?>
<style>
.top_mini4{background-image:url("<?php echo RES;?>m/img/my_bg.png");background-size:100%}
.my_msg_navbox:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.my_msg_nav a.ed spancolor:<?php echo $_ZEAI['mob_mbcolor'];?>}
.my_msg_navbox:before{background-image:url("<?php echo RES;?>m/img/my_bg.png");}
.my_msg_nav a.ed i{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
</style>
<div class="my_msg_navbox">
    <div class="my_msg_nav">
        <?php if(@in_array('chat',$navarr)){?><a href="<?php echo HOST;?>/m/my_msg.php?t=sx"><i class="ico sx">&#xe629;<?php echo $chatnum_str;?></i><span<?php echo ($t == 'sx')?' class="ed"':'';?>>私信聊天</span></a><?php }?>
        <a href="<?php echo HOST;?>/m/my_msg.php?t=tz"<?php ?>><i class="ico tz">&#xe657;<?php echo $tznum_str;?></i><span<?php echo ($t == 'tz')?' class="ed"':'';?>>系统通知</span></a>
        <?php if(@in_array('hi',$navarr)){?><a href="<?php echo HOST;?>/m/my_msg.php?t=hi"><i class="ico hi">&#xe6bd;<?php echo $hinum_str;?></i><span<?php echo ($t == 'hi')?' class="ed"':'';?>>收到招呼</span></a><?php }?>
        <a href="<?php echo HOST;?>/m/my_msg.php?t=see"><i class="ico see">&#xe626;<?php echo $seenum_str;?></i><span<?php echo ($t == 'see')?' class="ed"':'';?>>谁看过我</span></a>
    </div>
</div>
<?php
/*********私信*********/
if ($t == 'sx'){?>
    <main id='main' class='msg'>
	<?php
	$sql_ = " (uid=".$cook_uid." OR senduid=".$cook_uid.") AND ifdel<>".$cook_uid;
	$SQL = "SELECT id,uid,senduid,t,addtime,kind FROM ".__TBL_MSG__." A,(SELECT MAX(id) AS max_id FROM ".__TBL_MSG__." WHERE ".$sql_." GROUP BY senduid,uid) B WHERE A.id=B.max_id AND ".$sql_." ORDER BY A.id DESC";//,content
	$rt=$db->query($SQL);
	while($tmprows = $db->fetch_array($rt,'name')){if($tmprows['senduid'] == $cook_uid){$tmprows['senduid'] = $tmprows['uid'];}$arr[]=$tmprows;}
	if($arr){
		$list = msg_reset($arr);
		foreach ($list as $rows) {
			$senduid = $rows['senduid'];
			$tt      = $rows['t'];
			//$content = dataIO($rows['content'],'out');
			$addtime_str = date_str($rows['addtime']);
			//主表信息
			$row = $db->ROW(__TBL_USER__,"sex,grade,nickname,photo_s,photo_f,birthday,pay,areatitle,heigh,edu,photo_ifshow,flag","id=".$senduid);
			$sex      = $row[0];
			$grade    = $row[1];
			$nickname = trimhtml(dataIO($row[2],'out'));
			$nickname = (empty($nickname))?'uid:'.$senduid:$nickname;
			$photo_s  = $row[3];
			$photo_f  = $row[4];
			$birthday  = $row[5];
			$pay       = $row[6];
			$areatitle = $row[7];
			$heigh     = $row[8];
			$edu       = $row[9];
			$photo_ifshow = $row[10];
			$flag      = $row[11];
			$birthday_str = (getage($birthday)<=0)?'':getage($birthday).'岁';
			$heigh_str    = (empty($heigh))?'':' '.udata('heigh',$heigh);
			$aARR = explode(' ',$areatitle);$areatitle = $aARR[1].$aARR[2];
			$areatitle_str = (empty($areatitle))?'':' '.$areatitle;
			$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$flag.'","outkind":"url"}');			
			if($flag==-2)$nickname='***';
			//列表红点
			$inum     = $db->COUNT(__TBL_MSG__," new=1 AND ifdel=0 AND senduid=".$senduid." AND uid=".$cook_uid);
			$inum_str = ($inum>0)?'<i class="new">'.$inum.'</i>':'';
			//锁
			//if($chat_duifangfree[$grade]!=1){
			//	$MsgFlag = lock_msg($senduid);
			//}else{
			//	$MsgFlag=true;
			//}
			//if ($MsgFlag){
			//	if($tt == 2){$content = '[语音]';}elseif(strstr($content,"[/img]")){$content = preg_replace("/\[img\](.+?)\[\/img\]/is","<img src=".RES."bq/\\1.gif>",$content); }$dtcls = '';
			//}else{
				$content = $birthday_str.$heigh_str.' '.udata('pay',$pay).' '.udata('edu',$edu).$areatitle_str;
				//$dtcls = 'class="lock"';
			//}
		?>
		<dl>
			<dt uid="<?php echo $senduid; ?>"<?php echo $dtcls;?>><img src="<?php echo $photo_s_url; ?>"><i class="ico lockico">&#xe620;</i></dt>
			<dd><h4><?php echo uicon($sex.$grade).$nickname; ?></h4><h6><?php echo $content; ?></h6></dd>
			<span><?php echo $addtime_str; ?></span><?php echo $inum_str; ?>
            <strong>删除</strong>
		</dl>
	<?php }}else{?>
    	<div class="my_hn_no">
        	<h4>暂无消息</h4>
        	<img src="<?php echo $kf_wxpic_url; ?>"><h5 class="C999">加客服享受人工1对1服务</h5>
			<?php if (!empty($kf_tel)){?>
                <i class="ico ">&#xe7c1;</i> <a href="tel:<?php echo $kf_tel;?>" ><?php echo $kf_tel;?></a>
            <?php }else{?>
                <?php if (!empty($kf_mob)){?><i class="ico">&#xe7c1;</i> <a href="tel:<?php echo $kf_mob;?>"><?php echo $kf_mob;?></a><?php }?>
            <?php }?>
            <br><br>
        </div>
	<?php }?>
    </main>
    <script>msgsxFn();</script>
<?php
/*********通知*********/
}elseif($t=='tz' || $t=='hi'){?>
	<main id='main' class='msg'>
    <?php
	if(!in_array('gift',$navarr))$SQL = " AND kind<>2";
	if($t=='tz'){
		$SQL .= " AND kind<>3";
	}elseif($t=='hi'){
		$SQL .= " AND kind=3";
	}
	$rt=$db->query("SELECT id,senduid,title,content,new,kind,addtime FROM ".__TBL_TIP__." WHERE uid=".$cook_uid.$SQL." ORDER BY id DESC LIMIT 100");
	$total = $db->num_rows($rt);
	if ($total > 0) {
		for($i=1;$i<=$total;$i++) {
			$rows = $db->fetch_array($rt,'num');
			if(!$rows)break;
			$id      = $rows[0];
			$senduid = $rows[1];
			$new     = $rows[4];
			$kind    = $rows[5];
			$addtime_str = date_str($rows[6]);
			$new_str = ($new == 1)?'<b></b>':'';
			if ($kind == 2 || $kind == 3){
				$row = $db->NUM($senduid,"sex,grade,nickname,photo_s,photo_f,flag,photo_ifshow");
				$sex      = $row[0];
				$grade    = $row[1];
				$nickname = dataIO($row[2],'out');
				$nickname = (empty($nickname))?'uid:'.$senduid:$nickname;
				$photo_s  = $row[3];
				$photo_f  = $row[4];
				$flag     = $row[5];
                $photo_ifshow = $row[6];
				$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$flag.'","outkind":"url"}');
				if($flag==-2)$nickname='***';
				$img_str     = '<img src="'.$photo_s_url.'">';
				if($kind == 2){
					$kind_str = '<i class="ico k2">&#xe600;</i>';
				}elseif($kind == 3){
					$kind_str = '<i class="ico k3">&#xe6bd;</i>';
				}
				$title   = uicon($sex.$grade).$nickname;
				$content = dataIO($rows[3],'out');
			}else{//1,4
				if($kind == 1){
					$img_str = '<i class="ico k1">&#xe657;</i>';
					$title   = '系统消息';
				}elseif($kind == 4){
					$img_str = '<i class="ico k4">&#xe613;</i>';
					$title   = '红娘消息';
				}
				$kind_str = '';
				$content = dataIO($rows[2],'out');
			}
	?>
    <dl>
        <dt tid="<?php echo $id; ?>" kind="<?php echo $kind;?>"><?php echo $img_str; ?><?php echo $new_str; ?></dt>
        <dd><h4><?php echo $title; ?></h4><h6><?php echo $content; ?></h6></dd>
        <span><?php echo $addtime_str; ?></span><?php echo $kind_str; ?>
        <strong>删除</strong>
    </dl>
	<?php }
	}else{?>
    	<div class="my_hn_no">
        	<h4>暂无消息</h4>
        	<img src="<?php echo $kf_wxpic_url; ?>"><h5 class="C999">加客服享受人工1对1服务</h5>
			<?php if (!empty($kf_tel)){?>
                <i class="ico ">&#xe7c1;</i> <a href="tel:<?php echo $kf_tel;?>" ><?php echo $kf_tel;?></a>
            <?php }else{?>
                <?php if (!empty($kf_mob)){?><i class="ico">&#xe7c1;</i> <a href="tel:<?php echo $kf_mob;?>"><?php echo $kf_mob;?></a><?php }?>
            <?php }?>
            <br><br>
        </div>
	<?php }?>
	</main>
	<script>msgtzFn();</script>
<?php
/*********谁看过我*********/
}elseif($t=='see'){
	$viewlist = json_decode($_VIP['viewlist'],true);
	if ($viewlist[$cook_grade]!=1){?>
		<div class="viptips">
			<?php 
			$vwnum = $db->COUNT(__TBL_CLICKHISTORY__,"uid=".$cook_uid);
			$rt=$db->query("SELECT a.senduid,a.new,a.addtime,b.sex,b.photo_s,b.photo_f,b.photo_ifshow,b.flag FROM ".__TBL_CLICKHISTORY__." a,".__TBL_USER__." b WHERE a.senduid=b.id AND a.uid=".$cook_uid." ORDER BY a.addtime DESC LIMIT 6");
			$total = $db->num_rows($rt);
			if ($total > 0){
				echo '<div class="ivubox">';
				$viewblurClass = ($viewlist[$cook_grade]!=1)?' class="blur"':'';
				for($ii=1;$ii<=$total;$ii++) {
					$rows = $db->fetch_array($rt,'name');
					if(!$rows) break;
					$senduid = $rows['senduid'];
					$sex     = $rows['sex'];
					$new     = $rows['new'];
					$new_str = ($new == 1)?'<b></b>':'';
					$photo_s  = $rows['photo_s'];
					$photo_f  = $rows['photo_f'];
					$photo_ifshow  = $rows['photo_ifshow'];
					$uflag  = $rows['flag'];
					$photo_s_url = photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');
					echo '<span><img src="'.$photo_s_url.'"'.$viewblurClass.'></span>';
				}
				echo '</div>';
			}
			?>
			<font>最近有<b><?php echo $vwnum;?></b>人看过你</font>
			<h5>缘分就在一瞬间，不错过喜欢你的人</h5>
			<a href="my_vip.php?jumpurl=<?php echo urlencode(HOST.'/m/my_msg.php?t=see');?>" class="btn size3 zeaibg yuan" id="vipbtn">　<i class="ico">&#xe6ab;</i> 立即开通VIP查看　</a>
		</div>
	<?php }else{
		echo '<div class="seelist">';
		$rt=$db->query("SELECT a.id,a.senduid AS uid,a.new,a.addtime,b.nickname,b.sex,b.grade,b.photo_s,b.photo_f,b.areatitle,b.birthday,b.edu,b.pay,b.heigh,b.photo_ifshow,b.flag FROM ".__TBL_CLICKHISTORY__." a,".__TBL_USER__." b WHERE a.uid=".$cook_uid." AND a.senduid=b.id ORDER BY a.addtime DESC LIMIT 20");
		$total = $db->num_rows($rt);
		if ($total > 0) {
			for($i=1;$i<=$total;$i++) {
				$rows = $db->fetch_array($rt,'name');
				if(!$rows)break;
				$id      = $rows['id'];
				$uid     = $rows['uid'];
				$new     = $rows['new'];
				$addtime_str = date_str($rows['addtime']);
				$new_str = ($new == 1)?'<b></b>':'';
				//
				$nickname = trimhtml(dataIO($rows['nickname'],'out'));
				$sex      = $rows['sex'];
				$grade    = $rows['grade'];
				$photo_s  = $rows['photo_s'];
				$photo_f  = $rows['photo_f'];
				$flag     = $rows['flag'];
                $photo_ifshow = $rows['photo_ifshow'];
				$areatitle= $rows['areatitle'];
				$birthday = $rows['birthday'];
				$edu      = $rows['edu'];
				$pay      = $rows['pay'];
				$heigh    = $rows['heigh'];
				$edu_str       = (empty($edu))?'':''.'<b>/</b>'.udata('edu',$edu);
				$birthday_str  = (getage($birthday)<=0)?'':getage($birthday).'岁';
				$heigh_str     = (empty($heigh))?'':'<b>/</b>'.$heigh.'cm';
				$aARR = explode(' ',$areatitle);$areatitle = $aARR[1].$aARR[2];
				$areatitle_str = (empty($areatitle))?'':'<b>/</b>'.$areatitle;
				$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$flag.'","outkind":"url"}');
				if($flag==-2)$nickname='***';
				$O  = '<dl onClick="zeai.openurl(\''.a('{"kind":"u","uid":"'.$uid.'"}').'\')">';
				$O .= '<dt><img src="'.$photo_s_url.'"></dt>';
				$O .= '<dd><h4>'.uicon($sex.$grade).$nickname.'</h4><h6>'.$birthday_str.$heigh_str.$edu_str.$pay_str.$areatitle_str.'</h6></dd>';
				$O .= '<span>'.$addtime_str.'</span>';
				$O .= '</dl>';
				echo $O;
			}
		}else{?>
            <div class="my_hn_no seelist_no">
                <h4><i class="ico">&#xe659;</i>暂时还没有看过你</h4>
                <h5 class="C999">您可以<a href="<?php echo HOST;?>/m/my_info.php" class="zeaicolor">【上传头像】</a>照片，<a href="<?php echo HOST;?>/m/my_info.php" class="zeaicolor">【完善资料】</a>和<a href="<?php echo HOST;?>/m/my_cert.php" class="zeaicolor">【实名认证】</a>，通过<a href="<?php echo HOST;?>" class="zeaicolor">【置顶排名】</a>来提高自己爆光度和受众率</h5>
                <img src="<?php echo $kf_wxpic_url; ?>"><h5 class="C999">加客服享受人工1对1服务</h5>
                <?php if (!empty($kf_tel)){?>
                    <i class="ico ">&#xe7c1;</i> <a href="tel:<?php echo $kf_tel;?>" ><?php echo $kf_tel;?></a>
                <?php }else{?>
                    <?php if (!empty($kf_mob)){?><i class="ico">&#xe7c1;</i> <a href="tel:<?php echo $kf_mob;?>"><?php echo $kf_mob;?></a><?php }?>
                <?php }?>
                <br><br>
            </div>
		<?php }
			if($total>5){?><br><a href="<?php echo HOST;?>/m/my_browse.php?t=1" class="btn size3 zeaibg yuan">　点击查看更多　</a><?php }
		echo '</div>';?>
    
    <?php }?>
<?php }?>
<div class="kefubox" id="kefubox">
    <img src="<?php echo $kf_wxpic_url; ?>"><h5>加客服享受人工1对1服务</h5>
    <?php if (!empty($kf_tel)){?>
        <i class="ico ">&#xe7c1;</i> <a href="tel:<?php echo $kf_tel;?>" ><?php echo $kf_tel;?></a>
    <?php }else{?>
        <?php if (!empty($kf_mob)){?><i class="ico">&#xe7c1;</i> <a href="tel:<?php echo $kf_mob;?>"><?php echo $kf_mob;?></a><?php }?>
    <?php }?>
    <br><br>
</div>
<div id="msg_gift_box" class="box_gift">
    <em><img><h3></h3><h6></h6></em>
    <a href="javascript:;">看TA资料</a>
    <a href="javascript:;">回赠礼物</a>
</div>
<div id='tips0_100_msg_hi' class='tips0_100_0 alpha0_100_0'></div>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<div class="msg_yd" id="msg_yd"><img src="<?php echo RES;?>m/img/msg_yd.png"></div>
<?php require_once ZEAI.'m/TRnav.php';?>
<script>
var uid,lovebstr='<?php echo $_ZEAI['loveB'];?>';
if(zeai.empty(localStorage.msg_yd)){
	zeai.mask({maskcls:'mask1',son:msg_yd,cancelBubble:'off',close:function(){
		localStorage.msg_yd='wwwZEAIcn';
	}});
}
</script>
<?php
require_once ZEAI.'m/bottom.php';
ob_end_flush();
?>